package com.android.plc.ui.control;

import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;

import com.android.plc.CONST;
import com.android.plc.CONST.COMMAND;
import com.android.plc.R;

public class RoomControl extends NormalControl implements OnClickListener
{
	private static final String TAG = "RoomControl";

	public RoomControl(Context context, ViewGroup view)
	{
		super(context, view, R.layout.control_normal);
	}

	@Override
	public void initView(ViewGroup view)
	{
		super.initView(view);
		sendCommand(COMMAND.ALLHOMEONID, 0, 0);
	}

	public void onClick(View v)
	{
		switch (v.getId())
		{
		case R.id.btn_on:
			sendCommand(COMMAND.ALLHOMELTSON, CONST.DEF_DATA, 0);
			break;
		case R.id.btn_off:
			sendCommand(COMMAND.ALLHOMEUNITOFF, 0, 0);
			break;
		default:
			break;
		}
	}

	@Override
	public void onReceive(int command, int data1, int data2)
	{
		if (command == COMMAND.ALLHOMELTSON)
		{
			Log.w(TAG, "rev socket COMMAND.ALLHOMEONID");
			mOnBtn.setAlpha(OFF_ALPHA);
			mOffBtn.setAlpha(ON_ALPHA);
		} else if (command == COMMAND.ALLHOMEUNITOFF)
		{
			Log.w(TAG, "rev socket COMMAND.ALLHOMEUNITOFF");
			mOnBtn.setAlpha(ON_ALPHA);
			mOffBtn.setAlpha(OFF_ALPHA);
		} 
		
	}

}
